package com.luoxc.controller;

import com.luoxc.pojo.Emp;
import com.luoxc.pojo.Result;
import com.luoxc.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@RestController
public class LoginController {
    @Autowired
    private EmpService empService;
    @PostMapping("/login")
    private Result login(@RequestBody Emp emp){
        log.info("登录:" + emp.getUsername() + ":" + emp.getPassword());
        Map<String, Object> map = empService.login(emp);
        return map !=null ? Result.success(map) : Result.error("用户名或密码错误");
    }
}
